package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectPojo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingProjectController
 * @Author huangdongye
 * @Date 2025-05-08  11:27
 */

@RequestMapping("/nursing_project")
@RestController
@Api(tags = "护理项目管理")
public class NursingProjectController extends BaseController {
    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation("分页查询")
    public ResponseResult<PageResponse<NursingProjectVo>> getByPage(NursingProjectPojo pageNursing) {
        PageResponse<NursingProjectVo> nursingProjectPageInfo = nursingProjectService.getByPage(pageNursing);
        return success(nursingProjectPageInfo);
    }

    @PostMapping
    @ApiOperation("新增")
    public ResponseResult addNursingProject(@RequestBody NursingProjectVo nursingProject) {
        nursingProjectService.addNursingProject(nursingProject);
        return success();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<NursingProjectVo> getNursingProjectById(@PathVariable Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.getNursingProjectById(id);
        return success(nursingProjectVo);
    }

    @PutMapping
    @ApiOperation("修改")
    public ResponseResult updateNursingProject(@RequestBody NursingProjectVo npv) {

        nursingProjectService.updateNursingProject(npv);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("修改开关状态")
    public ResponseResult updateSwitch(@PathVariable Long id,
                                       @PathVariable int status) {
        nursingProjectService.updateSwitch(id,status);
        return success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public ResponseResult deleteNursingProject(@PathVariable Long id){
        nursingProjectService.deleteNursingProject(id);
        return success();
    }
    @GetMapping("/all")
    @ApiOperation("查询所有")
    public ResponseResult<List<NursingProjectVo>> allNursingProject(){
        List<NursingProjectVo> npv = nursingProjectService.allNursingProject();
        return success(npv);
    }


}
